package com.parenting.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;

import com.parenting.request.ShopperChildCheck;
import com.parenting.response.ShopperChildResponse;
import com.parenting.sevice.ShopperChildService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;


/**
 * <p>
 * 宝宝认证 前端控制器
 * </p>
 *
 * @author zcj
 * @since 2021-05-12
 */
@RestController
@RequestMapping("/plaza/shopperChild")
@Api(tags = "宝宝认证审核")
public class ShopperChildController {

    @Autowired
    private ShopperChildService shopperChildService;

    @ApiOperation(value = "获得宝宝的详情", httpMethod = "GET")
    @GetMapping("/childInfo/{id}")
    public Result<ShopperChildResponse> childInfo(@ApiParam(name = "id", value = "宝宝认证的ID", required = true)
                                              @PathVariable("id") @NotNull(message = "宝宝认证的ID不能为空") Long id) {
        return shopperChildService.childInfo(id);
    }


    @ApiOperation(value = "宝宝认证审核列表", httpMethod = "GET")
    @GetMapping("/childCheckList/{current}/{size}/{type}")
    public Result<Page<ShopperChildResponse>> childCheckList(@ApiParam(name = "current", value = "页码", required = true)
                                                         @PathVariable("current") @NotNull(message = "页码不能为空") Integer current,
                                                               @ApiParam(name = "size", value = "每页显示多少条", required = true)
                                                         @PathVariable("size") @NotNull(message = "每页显示多少条不能为空") Integer size,
                                                               @ApiParam(name = "type", value = "搜索类型1:全部2:待审核3:已审批4:已拒绝", required = true)
                                                         @PathVariable("type") @NotNull(message = "每页显示多少条不能为空") Integer type) {
        return shopperChildService.childCheckList(current, size, type);
    }


    @ApiOperation(value = "审核宝宝认证", httpMethod = "PUT")
    @PutMapping("/check/{id}")
    public Result check(@RequestBody @Validated ShopperChildCheck childDTO,
                        @ApiParam(name = "id", value = "宝宝认证的ID", required = true)
                          @PathVariable("id") @NotNull(message = "宝宝认证的ID不能为空") Long id) throws JsonProcessingException {
        return shopperChildService.check(childDTO, id);
    }
}

